package com.wwz.constants;

import com.baomidou.mybatisplus.plugins.Page;

import java.util.UUID;

public class JsonResult {

    private Object obj;

    private String code;

    private String message;

    private boolean isSuccess;

    private String token;

    public static JsonResult resolverPage(Page<?>page){

        return new JsonResult(page,true,"操作成功","200");
    }
    public static JsonResult resolverPageError(Page<?>page){
        return new JsonResult(page,false,"查询失败","201");
    }
    public JsonResult(Object o,boolean isSuccess,String message,String code){
        this.obj = o;
        this.isSuccess = isSuccess;
        this.message = message;
        this.code = code;
    }
    public static JsonResult resolver(LoginEnum loginEnum){
        if(Constants.OK.equals(loginEnum.getCode())){
            return new JsonResult(Constants.OK,true, LocalToken.Token.get(),"操作成功");
        }
        return new JsonResult(Constants.FAIL,false, "","操作失败");

    }

    public JsonResult(String code,boolean isSuccess,String token,String message){
        this.code = code;
        this.isSuccess = isSuccess;
        this.token = token;
        this.message = message;
    }

    public Object getObj() {
        return obj;
    }

    public void setObj(Object obj) {
        this.obj = obj;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public boolean isSuccess() {
        return isSuccess;
    }

    public void setSuccess(boolean success) {
        isSuccess = success;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }
}
